<?php
class usuarioController extends baseController
{
	public function listar()
	{
		$this->set( 'usuarios', $this->model->selectAll() ) ;
		$this->render() ;
	}
	
	public function login()
	{
		$usr 	= $this->post( 'usuario' ) ;
		$pass	= $this->post( 'clave' ) ;
		echo 'usuario: ' . $usr . ' - clave: ' . $pass ;
		if( $usr && $pass ){
			if( $this->auth( $usr, $pass ) )
			{
				$this->set( 'title', 'LOGUEADO' ) ;
				$this->render() ;
			}
			$this->set( 'title', 'Error al ingresar' ) ;
			$this->render() ;
		}else{		
		$this->set( 'title', 'Ingreso al Sistema' ) ;
		$this->render() ;
		}
	}
	
	private function auth( $usr, $pass )
	{
		$u = $this->model->selectWhere( array( 'USUARIO' => $usr ) ) ;
		echo 'asd' ;
		print_r( $u ) ;
		if( $u ){
			if( $u[ 'CLAVE' ] == $clave )
			{
				$return = true ;
			}
			else
			{
				$return = false ;
			}
		}
		else
		{
			$return = false ;
		}
		return $return;
	}
	
} // CLASS END